<{include file="public_html/header.html"}>
<{include file="public_html/left_menu.html"}>
	<!-- content starts -->
	<blockquote class="layui-elem-quote"><{$action}></blockquote>
	<div class="layui-tab layui-tab-card">
		<ul class="layui-tab-title">
			<li <{if isset($type) AND $type == 1}>class="layui-this"<{/if}>><a href="/school/edit/<{$school_info['id']|default:'0'}>/1">网校详情</a></li>
			<li <{if isset($type) AND $type == 2}>class="layui-this"<{/if}>><a href="/school/edit/<{$school_info['id']|default:'0'}>/2">网校老师</a></li>
			<!-- <li <{if isset($type) AND $type == 3}>class="layui-this"<{/if}>><a href="/school/edit/<{$school_info['id']|default:'0'}>/3">网校课程</a></li> -->
			
			<!-- <li <{if $type == 4}>class="layui-this"<{/if}>><a href="/school/edit/<{$school_info['id']|default:'0'}>/4">开通题库分类</a></li>
			<li <{if $type == 5}>class="layui-this"<{/if}>><a href="/school/edit/<{$school_info['id']|default:'0'}>/5">开通录播课</a></li> -->
			<li <{if isset($type) AND $type == 6}>class="layui-this"<{/if}>><a href="/school/edit/<{$school_info['id']|default:'0'}>/6">网校权限管理</a></li>
			<li <{if isset($type) AND $type == 7}>class="layui-this"<{/if}>><a href="/subject/school_tiku/0/<{$school_info['id']}>">网校题库</a></li>
			<li <{if isset($type) AND $type == 8}>class="layui-this"<{/if}>><a href="/question_topic/index/0/<{$school_info['id']}>">网校问答&话题</a></li>
			<li <{if isset($type) AND $type == 9}>class="layui-this"<{/if}>><a href="/news/index/0/<{$school_info['id']}>">网校资讯</a></li>
			<li <{if isset($type) AND $type == 11}>class="layui-this"<{/if}>><a href="/school_course?school_id=<{$school_info['id']}>">网校课程</a></li>
			<li <{if isset($type) AND $type == 12}>class="layui-this"<{/if}>><a href="/school/order_record/<{$school_info['id']}>">网校消费记录</a></li>
			<li <{if isset($type) AND $type == 13}>class="layui-this"<{/if}>><a href="/user/index/0/0/0/1/0/0/<{$school_info['id']}>">学员列表</a></li>
		</ul>
	</div>
	<fieldset class="layui-elem-field">
		<legend>按条件搜索</legend>
		<div class="layui-field-box">
			<form class="layui-form layui-form-pane1" method="post" id="order_form">
				<div class="layui-form-item">
					<div class="layui-input-inline">
						<select name="school_id" class="abc" lay-search="" lay-verify="required" id="cate_id" placeholder="请选择" lay-filter="cate_id">
							<option value="">网校</option>
							<{foreach from=$schools item=item}>
								<option value="<{$item.id}>" <{if $conditions['school_id'] eq $item.id}>selected="selected"<{/if}>><{$item.school_name}></option>
							<{/foreach}>
						</select>
					</div>

					<div class="layui-input-inline">
						<input class="layui-input" name="start_time" value="<{if $conditions['start_time']|default:0 != 0}><{$conditions['start_time']}><{/if}>" placeholder="开始日" id="LAY_demorange_s">
					</div>
					<div class="layui-form-mid">-</div>

					<div class="layui-input-inline">
						<input class="layui-input" name="end_time" value="<{if $conditions['end_time']|default:0 != 0}><{$conditions['end_time']}><{/if}>"  placeholder="截止日" id="LAY_demorange_e">
					</div>

					<div class="layui-inline">
						<button type="submit" class="layui-btn">搜索</button>
						<button type="button" class="layui-btn" id="total">统计金额</button>
						<button type="button" class="layui-btn" id="duihuan">兑换</button>
					</div>
				</div>
			</form>
		</div>
	</fieldset>
	<form class="layui-form layui-form-pane1" method="post" delete_action="/school/delete">
		<table class="layui-table" lay-even lay-skin="row">
			<thead>
				<tr>
					<th>网校名称</th>
					<th>商品名称</th>
					<th>代理商</th>
					<th>代理商提成</th>
					<th>单价*数量=总价格</th>
					<th>消费时间</th>
					<th>状态</th>
				</tr>
			</thead>
			<tbody>
			<{foreach from=$record_list item=item}>
				<tr>
					<td class="center"><{$item['school_name']}></td>
					<td class="center"><{if $item.data_type == 1}><{$item['title']}><{else}><{$item['ctitle']}><{/if}></td>
					<td class="center"><{$item['agent_name']}></td>
					<td class="center"><{if $item['agent_points'] > 0}><{$item['agent_points']}>%(<{$item['commission']}>元)<{else}>--<{/if}></td>
					<td class="center"><{$item['price']}> * <{$item['num']}> = <{$item['price']*$item['num']}>元</td>
					<td class="center"><{$item['add_time']|date_format:'%Y-%m-%d <br> %H:%M:%S'}></td>
					<td class="center"><{if $item['commission_status']== 0}>未兑换<{else}>已兑换<{/if}></td>
					<!-- <td class="center">
					<a class="layui-btn layui-btn-primary layui-btn-small" href="/school/edit/<{$item['id']}>" target="_blank"><i class="layui-icon"></i></a>
					<a class="layui-btn layui-btn-primary layui-btn-small delete_data" href="/school/delete/<{$item['id']}>"><i class="layui-icon"></i></a>
					</td> -->
				</tr>
			<{/foreach}>
			</tbody>
		</table>
	</form>
	<div class="layui-box layui-laypage layui-laypage-default">
		<{$pagination}>
	</div>

<{include file="public_html/footer.html"}>
<script>
	layui.use('laydate', function(){
		var laydate = layui.laydate;
		var start = {
			min: '2016-11-31 23:59:59'
			,max: laydate.now(+1)
			,istoday: false
			,choose: function(datas){
				end.min = datas; //开始日选好后，重置结束日的最小日期
				end.start = datas //将结束日的初始值设定为开始日
			}
		};

		var end = {
			min: '2016-11-31 23:59:59'
			,max: laydate.now(+1)
			,istoday: false
			,choose: function(datas){
				start.max = datas; //结束日选好后，重置开始日的最大日期
			}
		};

		document.getElementById('LAY_demorange_s').onclick = function(){
			start.elem = this;
			laydate(start);
		}
		document.getElementById('LAY_demorange_e').onclick = function(){
			end.elem = this
			laydate(end);
		}
	});

	$("#total, #duihuan").click(function(){
		var _this = $(this);
		var data = $("#order_form").serializeArray();
		if(_this.attr("id") == 'duihuan'){
			var o = new Object();
			o.name = 'status';
			o.value = 0;
			data.push(o)
		}
		$.ajax({
			type: "POST",
			url: "/school/order_record_amount",
			dataType:"json",
			async:false,
			data:data,
			contentType:'application/x-www-form-urlencoded',
			success: function(result){
				if(_this.attr("id") == 'total'){
					layer.open({
				  		title: '金额统计',
				  		content: "当前订单总金额为:"+result.price+"元，佣金为:"+result.points+"元"
					});
				}else{
					if(result.price > 0){
						layer.confirm("当前可兑换的订单总金额为:"+result.price+"元，佣金为:"+result.points+"元，是否确定兑换？", {
						  	btn: ['确定','取消'] //按钮
						}, function(){
							$.ajax({
								type: "POST",
								url: "/school/duihuan_order_record_amount",
								dataType:"json",
								async:false,
								data:data,
								contentType:'application/x-www-form-urlencoded',
								success: function(result){
									layer.msg('的确很重要', {icon: 1});
								}
							});
						}, function(){
						  	
						});
					}else{
						layer.open({
					  		title: '金额统计',
					  		content: "当前没有可兑换金额"
						});
					}
				}
			}
		});
	})
</script>